/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifRegistrarLicitacion.java
 *
 * Created on 03-ago-2010, 15:21:55
 */

package Licitaciones;

import administracion.BeanBinding.TblBeanBindingDetalleLicitacion;
import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.LimitaCaracteres;
import administracion.helper.Listas;
import administracion.helper.MiTablePrint;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_Tabla;
import administracion.helper.Utiles_Validar;
import administracion.helper.VerificarDatos;
import administracion.propiedades.Propiedades;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.MaskFormatter;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.EmpresaTO;
import suministros.ejb30.TO.ProveedorTO;
import suministros.ejb30.TO.TipoTO;
import suministros.ejb30.entity.DetalleLicitacion;
import suministros.ejb30.entity.DetalleLicitacionPK;
import suministros.ejb30.entity.Licitacion;
import suministros.ejb30.entity.Proveedor;
import suministros.ejb30.helper.Utiles_Convertir;

/**
 *
 * @author Diana
 */
public class jifRegistrarLicitacion extends javax.swing.JInternalFrame {
    public List<TblBeanBindingDetalleLicitacion> detalleLicitacion;
    private MaskFormatter mascaraFecha;
    private MaskFormatter mascaraCodigo;
    private JTableBinding jTableBinding;
    private ListDataIntelliHints intelliHintsProveedor;
    private Proveedor proveedor;
    List listaTipos = null;
     JFrame padrev;
     List<EmpresaTO> empresas;
    /** Creates new form jifRegistrarLicitacion */
    public jifRegistrarLicitacion( JFrame padrev) {
        construirMascaras();
        empresas = Listas.getEmpresas();
        if(empresas.isEmpty()){
            this.jCheckBox1.setEnabled(false);
        }
        this.detalleLicitacion = new ArrayList(1);
        this.padrev=padrev;
        initComponents();
        this.llenarComboTipo();

        this.llenarComboTipoFormaPago();
        this.jCheckBox1.setSelected(false);
        this.llenarComboEmpresa();
        try {
            cargaHintsIndependientes();
        } catch (Exception ex) {
            Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
        }
          this.jcbEmpresa.setEnabled(false);
    }
    private void llenarComboEmpresa() {
        empresas = null;
        List listaPaises_cbo = this.cboBeanBindingEmpresa1.getLista();
        listaPaises_cbo.clear();
        try
        {
          if(this.jCheckBox1.isSelected()){
                empresas = Listas.getEmpresas();
            }
            else{
                empresas = Listas.getEmpresaPrincipal();
            }
          this.cboBeanBindingEmpresa1.setLista(empresas);
          this.bindingGroup.bind();
          this.jcbEmpresa.updateUI();
          this.jcbEmpresa.setSelectedIndex(0);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener empresas\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
     private void construirMascaras() {
    try {
      this.mascaraFecha = new MaskFormatter("##/##/####");
      //this.mascaraCodigo= new MaskFormatter("##########");
    } catch (ParseException ex) {
      Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
      ex.printStackTrace();
    }
  }
   private void cargaHintsIndependientes() throws Exception {
    this.intelliHintsProveedor = new ListDataIntelliHints(this.jtfProveedor, Listas.getProveedores());
  }
      private void llenarComboTipo() {
        List listaTipos_cbo1 = this.cboBeanBindingTipo1.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos = Listas.getTipo_porTabla("tipo_licitacion");
           this.cboBeanBindingTipo1.setLista(listaTipos);
          this.bindingGroup.bind();
          this.jcboTipo.updateUI();
          this.jcboTipo.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener tipos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
     private void llenarComboTipoFormaPago() {
        List listaTipos2 = null;
        List listaTipos_cbo2 = this.cboBeanBindingTipo2.getLista();
        listaTipos_cbo2.clear();
        try
        {
          listaTipos2 = Listas.getTipo_porTabla("Tipo_FormaPago");

          this.cboBeanBindingTipo2.setLista(listaTipos2);
          this.bindingGroup.bind();
          this.jcboFormaPago.updateUI();
          this.jcboFormaPago.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Formas de Pago\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
   private void buscarRazonSocial()
      {
        ProveedorTO pro;
        if (this.jtfRuc.getText().trim().length() < 1) {
              try { pro = (ProveedorTO)this.intelliHintsProveedor.getSelectedHint();
              } catch (NullPointerException ex) {
                pro = null;
              }
            }
        else {
          pro = Listas.getProveedorcodigo(this.jtfRuc.getText().trim());
        }
        if (pro == null) {
          Utiles_MensajesDialogo.mensajeError("El proveedor no existe!");
          this.jtfRuc.setText("");
          pro = null;
        }
        else {
          this.proveedor = Utiles_Convertir.convertirToProveedor_ProveedorTO(pro);
          this.jtfRuc.setText(pro.getRazon() + " - " + pro.getCodProveedor());
          this.jtfRuc.setText(pro.getCodProveedor());
          this.jftfFechaInicio.requestFocus();
        }

      }
     void agregaDetalleSuministro(TblBeanBindingDetalleLicitacion detalle) throws Exception {
    try {

      if (verificaNoExisteSuministro(detalle)) {
        this.detalleLicitacion.add(detalle);
        actualizaTablaDetalle();
      } else {
        throw new Exception("El suministro " + detalle.getDesc_suministro().trim() + "\nya fue ingresado");
      }
    } catch (Exception e) {
      throw e;
    }
  }
    private boolean verificaNoExisteSuministro(TblBeanBindingDetalleLicitacion detalle) {
    boolean retorno = true;
    for (TblBeanBindingDetalleLicitacion det : this.detalleLicitacion) {
      if (det.getId_suministro().equalsIgnoreCase(detalle.getId_suministro())) {
        retorno = false;
        break;
      }
    }
    return retorno;
  }

     private boolean verificaNoExisteSuministroEnPedido(TblBeanBindingDetalleLicitacion detalle) {
        boolean retorno = true;
        for (TblBeanBindingDetalleLicitacion det : this.detalleLicitacion) {
          if (det.getId_suministro().equalsIgnoreCase(detalle.getId_suministro())) {
            retorno = false;
            break;
          }
        }
        return retorno;
      }
       public void actualizaTablaDetalle() {
        this.bindingGroup = new BindingGroup();
        this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.detalleLicitacion, this.jtDetalleSuministro);

        JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${id_suministro}"));

        columnBinding0.setColumnName("ID Suministro");
        columnBinding0.setColumnClass(String.class);
        columnBinding0.setEditable(false);

        JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${desc_suministro}"));

        columnBinding1.setColumnName("Suministro");
        columnBinding1.setColumnClass(String.class);
        columnBinding1.setEditable(false);

        JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidad}"));

        columnBinding2.setColumnName("Cantidad");
        columnBinding2.setColumnClass(BigDecimal.class);
        columnBinding2.setEditable(true);

        JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${precio}"));

        columnBinding3.setColumnName("Precio");
        columnBinding3.setColumnClass(BigDecimal.class);
        columnBinding3.setEditable(false);

        JTableBinding.ColumnBinding columnBinding4 = this.jTableBinding.addColumnBinding(ELProperty.create("${precioTotal}"));

        columnBinding4.setColumnName("Prec.Total");
        columnBinding4.setColumnClass(BigDecimal.class);
        columnBinding4.setEditable(false);

         JTableBinding.ColumnBinding columnBinding5 = this.jTableBinding.addColumnBinding(ELProperty.create("${migracion}"));

        columnBinding5.setColumnName("Actividades");
        columnBinding5.setColumnClass(String.class);
        columnBinding5.setEditable(false);

        this.bindingGroup.addBinding(this.jTableBinding);
        this.bindingGroup.bind();

          int[] porcentajes= {15,45,10,10,10,10};
        try {
            Utiles_Tabla.definirAnchoColumnasJTable(jtDetalleSuministro, porcentajes);
             //MiTablePrint.autoSizeTableColumns(this.jtDetalleSuministro);
        } catch (Exception ex) {
            Logger.getLogger(jdAdministrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (this.detalleLicitacion.size() > 0) {
          this.jbAceptar.setEnabled(true);
          this.jbEliminaDetalle.setEnabled(true);
          this.jbtnAgregar.setEnabled(false);
          this.jbAceptar.requestFocus();
        } else {
          this.jbAceptar.setEnabled(false);
          this.jbAgregarDetalle.requestFocus();
          this.jbEliminaDetalle.setEnabled(false);
          this.jbtnAgregar.setEnabled(false);
        }
      }
       private void eliminarFila() {
        String id_sumi = this.jtDetalleSuministro.getValueAt(this.jtDetalleSuministro.getSelectedRow(), 0).toString().trim();

        for (TblBeanBindingDetalleLicitacion det : this.detalleLicitacion) {
          if (det.getId_suministro().equalsIgnoreCase(id_sumi)) {
            this.detalleLicitacion.remove(det);
            break;
          }
        }
        actualizaTablaDetalle();
      }

     public   void cerrar(){
      int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
      "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
            if(res==javax.swing.JOptionPane.YES_OPTION){
                    this.dispose();

         }
      }
      public EmpresaTO obtenerEmpresa(String codigo){
        EmpresaTO dep= new EmpresaTO();
        for(int i=0 ; i<this.empresas.size(); i++){
            if((((EmpresaTO)empresas.get(i)).getCodigo().trim()).compareTo(codigo)==0){
                dep= (EmpresaTO)empresas.get(i);
            }
        }
        return dep;
    }
     public boolean registrarLicitacion(){
         boolean estado=true;
        try {

            List<DetalleLicitacion> lista= new ArrayList();
            Date fechaFin = new Date(VerificarDatos.verificaFecha(this.jftfFechaFin.getText()).getTime());
            Date fechaInicio = new Date(VerificarDatos.verificaFecha(this.jftfFechaInicio.getText()).getTime());
            if(fechaInicio.after(fechaFin)){
                Utiles_MensajesDialogo.mensajeError("La fecha de fin no puede ser antes que la de inicio");
                estado=false;
            }
            else{
                Licitacion lic = new Licitacion();
                lic.setCodProceso(this.jtfCodigo.getText());
                lic.setCodProveedor(proveedor);
                lic.setDescripcionProceso(this.jtfDescripcion.getText());
                lic.setIdTablaTipo(Utiles_Convertir.convertirToTipo_TipoTO((TipoTO) this.jcboTipo.getSelectedItem()));
                lic.setFechaInicio(fechaInicio);
                lic.setFechaFin(fechaFin);
                lic.setMontoAdquirido(BigDecimal.ZERO);
                lic.setIsAlta(true);
                lic.setEmpresa(Utiles_Convertir.convertirToEmpresa_EmpresaTO((EmpresaTO)this.jcbEmpresa.getSelectedItem()));
                lic.setIdformaPago(Utiles_Convertir.convertirToTipo_TipoTO((TipoTO) this.jcboFormaPago.getSelectedItem()));
                lic.setMontoTotal(new BigDecimal(this.jtfMonto.getText()));
                 for (TblBeanBindingDetalleLicitacion deta : this.detalleLicitacion) {
                  DetalleLicitacion detall = new DetalleLicitacion(this.jtfCodigo.getText(), deta.getId_suministro());
                  detall.setCantidad(deta.getCantidad());
                  detall.setPrecio(deta.getPrecio());
                  detall.setPrecioTotal(deta.getPrecioTotal());
                  detall.setCantidadAdquirida(BigDecimal.ZERO);
                  detall.setMontoAdquirido(BigDecimal.ZERO);
                  lista.add(detall);

                  }
                  BigDecimal sumatotal=BigDecimal.ZERO;
                  for(int i=0; i<detalleLicitacion.size(); i++){

                    BigDecimal monto=detalleLicitacion.get(i).getCantidad().multiply(detalleLicitacion.get(i).getPrecio());
                    sumatotal=sumatotal.add(monto);
                 }
                 if((new BigDecimal(this.jtfMonto.getText())).compareTo(sumatotal)!=0){
                    int res1 = javax.swing.JOptionPane.showConfirmDialog( this,"El monto total '"+this.jtfMonto.getText()+"' no coincide con el ingresado en los detalles '"+sumatotal+"' \n ¿Desea modificar el monto de la licitacion",
                    "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
                     if(res1==javax.swing.JOptionPane.YES_OPTION){
                        lic.setMontoTotal(sumatotal.setScale(2));
                        this.jtfMonto.setText(sumatotal.setScale(2)+"");
                     }
                 }
              GestionPedidosDelegate.getInstance().insertarLicitacion(Propiedades.getUsuario(),Propiedades.getMac(),lic, lista);
              }
         } catch (Exception ex) {
                Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
         }
         return estado;
     }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo2 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingEmpresa1 = new administracion.BeanBinding.CboBeanBindingEmpresa();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtfDescripcion = new javax.swing.JTextField();
        jtfRuc = new javax.swing.JTextField();
        jtfProveedor = new javax.swing.JTextField();
        jtfMonto = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtDetalleSuministro = new javax.swing.JTable();
        this.jtDetalleSuministro.getTableHeader().setReorderingAllowed(false) ;
        jbAgregarDetalle = new javax.swing.JButton();
        jbEliminaDetalle = new javax.swing.JButton();
        jbtnAgregar = new javax.swing.JButton();
        jbAceptar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jcboTipo = new javax.swing.JComboBox();
        jftfFechaFin = new JFormattedTextField(this.mascaraFecha);
        jftfFechaInicio = new JFormattedTextField(this.mascaraFecha);
        jLabel9 = new javax.swing.JLabel();
        jcboFormaPago = new javax.swing.JComboBox();
        jcbEmpresa = new javax.swing.JComboBox();
        jtfCodigo = new javax.swing.JTextField();
        jCheckBox1 = new javax.swing.JCheckBox();

        setIconifiable(true);
        setTitle("REGISTRAR LICITACIONES");

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("CODIGO DE PROCESO:");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("DESCRIPCION DE PROCESO:");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel3.setText("FECHA INICIO:");

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel4.setText("FECHA FIN:");

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("MONTO TOTAL:");

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel6.setText("RUC DE PROVEEDOR:");

        jLabel7.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        jLabel7.setText("PROVEEDOR:");

        jtfDescripcion.setFont(new java.awt.Font("Arial", 0, 12));
        jtfDescripcion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescripcionKeyPressed(evt);
            }
        });

        jtfRuc.setFont(new java.awt.Font("Arial", 0, 12));
        jtfRuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfRucActionPerformed(evt);
            }
        });

        jtfProveedor.setFont(new java.awt.Font("Arial", 0, 12));
        jtfProveedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfProveedorActionPerformed(evt);
            }
        });
        jtfProveedor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfProveedorKeyPressed(evt);
            }
        });

        jtfMonto.setFont(new java.awt.Font("Arial", 0, 12));
        jtfMonto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfMontoKeyPressed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "SUMINISTROS ASIGNADOS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jtDetalleSuministro.setFont(new java.awt.Font("Arial", 0, 12));
        jtDetalleSuministro.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "CODIGO", "DENOMINACION", "UNIDAD", "CANTIDAD", "PRECIO", "PRECIO TOTAL"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jtDetalleSuministro);

        jbAgregarDetalle.setFont(new java.awt.Font("Arial", 0, 12));
        jbAgregarDetalle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/add.png"))); // NOI18N
        jbAgregarDetalle.setMnemonic('G');
        jbAgregarDetalle.setText("AGREGAR");
        jbAgregarDetalle.setToolTipText("Agregar un detalle al pedido");
        jbAgregarDetalle.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jbAgregarDetalle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAgregarDetalleActionPerformed(evt);
            }
        });
        jbAgregarDetalle.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbAgregarDetalleKeyPressed(evt);
            }
        });

        jbEliminaDetalle.setFont(new java.awt.Font("Arial", 0, 12));
        jbEliminaDetalle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/remove.png"))); // NOI18N
        jbEliminaDetalle.setMnemonic('E');
        jbEliminaDetalle.setText("ELIMINAR");
        jbEliminaDetalle.setToolTipText("Eliminar el detalle seleccionado");
        jbEliminaDetalle.setEnabled(false);
        jbEliminaDetalle.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jbEliminaDetalle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbEliminaDetalleActionPerformed(evt);
            }
        });
        jbEliminaDetalle.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbEliminaDetalleKeyPressed(evt);
            }
        });

        jbtnAgregar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtnAgregar.setText("AÑADIR ACT.");
        jbtnAgregar.setEnabled(false);
        jbtnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnAgregarActionPerformed(evt);
            }
        });

        jbAceptar.setFont(new java.awt.Font("Arial", 0, 12));
        jbAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbAceptar.setMnemonic('A');
        jbAceptar.setText("ACEPTAR");
        jbAceptar.setToolTipText("Registrar el pedido");
        jbAceptar.setEnabled(false);
        jbAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAceptarActionPerformed(evt);
            }
        });
        jbAceptar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbAceptarKeyPressed(evt);
            }
        });

        jbCancelar.setFont(new java.awt.Font("Arial", 0, 12));
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbCancelar.setMnemonic('C');
        jbCancelar.setText("CERRAR");
        jbCancelar.setToolTipText("Cancelar la Operacion");
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });
        jbCancelar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbCancelarKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(312, 312, 312)
                        .addComponent(jbAgregarDetalle)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbEliminaDetalle)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                        .addComponent(jbtnAgregar))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 648, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(198, Short.MAX_VALUE)
                .addComponent(jbAceptar)
                .addGap(18, 18, 18)
                .addComponent(jbCancelar)
                .addGap(242, 242, 242))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbAgregarDetalle)
                    .addComponent(jbEliminaDetalle)
                    .addComponent(jbtnAgregar))
                .addGap(8, 8, 8)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbAceptar)
                    .addComponent(jbCancelar))
                .addGap(31, 31, 31))
        );

        jLabel8.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel8.setText("TIPO DE LICITACION:");

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo1, eLProperty, jcboTipo);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboTipo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboTipoKeyPressed(evt);
            }
        });

        jftfFechaFin.setToolTipText("Fecha de Fin");
        jftfFechaFin.setFont(new java.awt.Font("Arial", 0, 12));
        jftfFechaFin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftfFechaFinActionPerformed(evt);
            }
        });
        jftfFechaFin.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftfFechaFinKeyPressed(evt);
            }
        });

        jftfFechaInicio.setToolTipText("Fecha de Inicio");
        jftfFechaInicio.setFont(new java.awt.Font("Arial", 0, 12));
        jftfFechaInicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftfFechaInicioActionPerformed(evt);
            }
        });
        jftfFechaInicio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jftfFechaInicioKeyPressed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        jLabel9.setText("PLAZO PAGO:");

        jcboFormaPago.setFont(new java.awt.Font("Arial", 0, 12));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo2, eLProperty, jcboFormaPago);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboFormaPago.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboFormaPagoItemStateChanged(evt);
            }
        });
        jcboFormaPago.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboFormaPagoActionPerformed(evt);
            }
        });
        jcboFormaPago.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboFormaPagoKeyPressed(evt);
            }
        });

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingEmpresa1, eLProperty, jcbEmpresa);
        bindingGroup.addBinding(jComboBoxBinding);

        jcbEmpresa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcbEmpresaKeyPressed(evt);
            }
        });

        jtfCodigo.setFont(new java.awt.Font("Arial", 0, 12));
        jtfCodigo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfCodigoKeyPressed(evt);
            }
        });

        jCheckBox1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jCheckBox1.setText("OTRAS EMPRESAS");
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBox1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel6)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5)
                            .addComponent(jLabel1))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jtfDescripcion)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jtfMonto, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jtfRuc, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jftfFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(18, 18, 18)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel7)
                                        .addComponent(jLabel4))
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(3, 3, 3)
                                            .addComponent(jftfFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel9)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jcboFormaPago, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jtfProveedor))))
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jcbEmpresa, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                            .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel8)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jcboTipo, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCheckBox1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcboTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(10, 10, 10))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtfDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(15, 15, 15)
                        .addComponent(jLabel3))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfRuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(jtfProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(9, 9, 9)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jftfFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(jftfFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9)
                            .addComponent(jcboFormaPago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addComponent(jLabel5))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfMonto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbAgregarDetalleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAgregarDetalleActionPerformed

        Frame frm = JOptionPane.getFrameForComponent((JInternalFrame)this);
        JDialog dialog = new JDialog(frm, true);
        dialog.setLocationRelativeTo(frm);
        dialog.setTitle("Insertar Detalles de Licitaciones");
        dialog.setDefaultCloseOperation(0);
        jpAgregaDetalleLicitacion panel = new jpAgregaDetalleLicitacion(dialog, this);
        dialog.add(panel);
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
}//GEN-LAST:event_jbAgregarDetalleActionPerformed

    private void jbAgregarDetalleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbAgregarDetalleKeyPressed
       
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbAgregarDetalle.doClick();
        }
}//GEN-LAST:event_jbAgregarDetalleKeyPressed

    private void jbEliminaDetalleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbEliminaDetalleActionPerformed
       
        try {
            if (this.jtDetalleSuministro.getSelectedRow() < 0) {
                Utiles_MensajesDialogo.mensajeError("Debe elegir un detalle");
                return;
            }
            if (Utiles_MensajesDialogo.mensajeConfirmacion("Esta seguro de eliminar el detalle?"))
                eliminarFila();
        } catch (Exception e) {
            e.printStackTrace();
        }
}//GEN-LAST:event_jbEliminaDetalleActionPerformed

    private void jbEliminaDetalleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbEliminaDetalleKeyPressed
       
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbEliminaDetalle.doClick();
        }
}//GEN-LAST:event_jbEliminaDetalleKeyPressed

    private void jbAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAceptarActionPerformed

         int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro que desea registrar esta licitacion?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
         if(res==javax.swing.JOptionPane.YES_OPTION){
                 if(this.jtfCodigo.getText().length()>10){
                      Utiles_MensajesDialogo.mensajeAlerta("El codigo del proceso solo puede tener 10 digitos");
                 }
                 else{
                      try {
                      if(registrarLicitacion()){
                         Utiles_MensajesDialogo.mensajeExito();
                        this.jbAgregarDetalle.setEnabled(false);
                        this.jbEliminaDetalle.setEnabled(false);
                        this.jbtnAgregar.setEnabled(true);
                        this.jbAceptar.setEnabled(false);
                        }
                      }catch (Exception ex) {
                            Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
                            Utiles_MensajesDialogo.mensajeError("No se puedo registrar la licitacion");
                       }
                  }
       }
    }//GEN-LAST:event_jbAceptarActionPerformed

    private void jbAceptarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbAceptarKeyPressed
       
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbAceptar.doClick();
        }
}//GEN-LAST:event_jbAceptarKeyPressed

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed
      
        cerrar();
}//GEN-LAST:event_jbCancelarActionPerformed

    private void jbCancelarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbCancelarKeyPressed
        
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbCancelar.doClick();
        }
}//GEN-LAST:event_jbCancelarKeyPressed

    private void jftfFechaFinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftfFechaFinActionPerformed
       


    }//GEN-LAST:event_jftfFechaFinActionPerformed

    private void jftfFechaInicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftfFechaInicioActionPerformed
        
    }//GEN-LAST:event_jftfFechaInicioActionPerformed

    private void jtfProveedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfProveedorActionPerformed
        buscarRazonSocial();
    }//GEN-LAST:event_jtfProveedorActionPerformed

    private void jtfProveedorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfProveedorKeyPressed
         if (this.jtfRuc.getText().trim().length() > 0)
            this.jtfRuc.setText("");
    }//GEN-LAST:event_jtfProveedorKeyPressed

    private void jtfRucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfRucActionPerformed
        if (this.jtfRuc.getText().trim().length() < 1)
            this.jtfProveedor.requestFocus();
        else{
             buscarRazonSocial();
        }


    }//GEN-LAST:event_jtfRucActionPerformed

    private void jbtnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAgregarActionPerformed
        int filaElegida = this.jtDetalleSuministro.getSelectedRow();
        if (filaElegida < 0) {
          Utiles_MensajesDialogo.mensajeError("Debe elegir un suministro!");
          this.jtDetalleSuministro.requestFocus();
        }
        else{
            String codigo=this.jtfCodigo.getText();
            String suministro=this.jtDetalleSuministro.getValueAt(filaElegida, 0).toString();
            String descripcion=this.jtDetalleSuministro.getValueAt(filaElegida, 1).toString();
            BigDecimal monto= this.detalleLicitacion.get(this.jtDetalleSuministro.convertRowIndexToModel(filaElegida)).getPrecioTotal();
            jdAgregarActividades jdAgregaDetalle=new jdAgregarActividades(this,padrev,true, codigo, suministro, descripcion, filaElegida, monto);
            jdAgregaDetalle.setLocationRelativeTo(null);
            jdAgregaDetalle.setPadreDetalle(this);
            jdAgregaDetalle.setVisible(true);
        }
      
    }//GEN-LAST:event_jbtnAgregarActionPerformed

    private void jcboTipoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboTipoKeyPressed
        if(KeyEvent.VK_ENTER == evt.getKeyCode()){
            this.jtfDescripcion.requestFocus();
        }
    }//GEN-LAST:event_jcboTipoKeyPressed

    private void jtfDescripcionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescripcionKeyPressed
        if(KeyEvent.VK_ENTER == evt.getKeyCode()){
            this.jtfRuc.requestFocus();
        }
    }//GEN-LAST:event_jtfDescripcionKeyPressed

    private void jftfFechaInicioKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftfFechaInicioKeyPressed
        if(KeyEvent.VK_ENTER == evt.getKeyCode()){
            this.jftfFechaFin.requestFocus();
        }
    }//GEN-LAST:event_jftfFechaInicioKeyPressed

    private void jtfMontoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfMontoKeyPressed
         if(KeyEvent.VK_ENTER == evt.getKeyCode()){
            this.jbAgregarDetalle.requestFocus();
        }
    }//GEN-LAST:event_jtfMontoKeyPressed

    private void jftfFechaFinKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftfFechaFinKeyPressed
        if(KeyEvent.VK_ENTER == evt.getKeyCode()){
            this.jtfMonto.requestFocus();
        }
    }//GEN-LAST:event_jftfFechaFinKeyPressed

    private void jcboFormaPagoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboFormaPagoItemStateChanged
        
    }//GEN-LAST:event_jcboFormaPagoItemStateChanged

    private void jcboFormaPagoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboFormaPagoKeyPressed

        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jtfMonto.requestFocus();
        }
}//GEN-LAST:event_jcboFormaPagoKeyPressed

    private void jtfCodigoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfCodigoKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
             if(this.jtfCodigo.getText().length()<=10){
             this.jcboTipo.requestFocus();
             }
             else{
             this.jtfCodigo.setText("");
             this.jtfCodigo.requestFocus();
             Utiles_MensajesDialogo.mensajeAlerta("El codigo del proceso solo puede tener 10 digitos");
             }

        }
    }//GEN-LAST:event_jtfCodigoKeyPressed

    private void jcbEmpresaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbEmpresaKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            if(this.jcbEmpresa.getSelectedIndex()>=0){
                this.jtfCodigo.requestFocus();
            }
        }
    }//GEN-LAST:event_jcbEmpresaKeyPressed

    private void jcboFormaPagoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboFormaPagoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcboFormaPagoActionPerformed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        if(this.jCheckBox1.isSelected()){
            this.jcbEmpresa.setEnabled(true);
        } else{
            this.jcbEmpresa.setEnabled(false);
        }
        this.llenarComboEmpresa();

}//GEN-LAST:event_jCheckBox1ActionPerformed



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private administracion.BeanBinding.CboBeanBindingEmpresa cboBeanBindingEmpresa1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo2;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbAceptar;
    private javax.swing.JButton jbAgregarDetalle;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbEliminaDetalle;
    private javax.swing.JButton jbtnAgregar;
    private javax.swing.JComboBox jcbEmpresa;
    private javax.swing.JComboBox jcboFormaPago;
    private javax.swing.JComboBox jcboTipo;
    private javax.swing.JFormattedTextField jftfFechaFin;
    private javax.swing.JFormattedTextField jftfFechaInicio;
    public javax.swing.JTable jtDetalleSuministro;
    private javax.swing.JTextField jtfCodigo;
    private javax.swing.JTextField jtfDescripcion;
    public javax.swing.JTextField jtfMonto;
    private javax.swing.JTextField jtfProveedor;
    private javax.swing.JTextField jtfRuc;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

}
